home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / STRSTREA.H < prev    next >
C/C++ Source or Header  |  1993-11-23  |  3KB  |  96 lines

  1. /***
  2. *strstream.h - definitions/declarations for strstreambuf, strstream
  3. *
  4. *   Copyright (c) 1991-1992, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *   This file defines the classes, values, macros, and functions
  8. *   used by the strstream and strstreambuf classes.
  9. *   [AT&T C++]
  10. *
  11. ****/
  12.  
  13. #ifndef _INC_STRSTREAM
  14. #define _INC_STRSTREAM
  15.  
  16. #include <iostream.h>
  17.  
  18. // Force word packing to avoid possible -Zp override
  19. #pragma pack(2)
  20.  
  21. #pragma warning(disable:4505)       // disable unwanted /W4 warning
  22. // #pragma warning(default:4505)    // use this to reenable, if necessary
  23.  
  24. #ifdef M_I86HM
  25. #define _HFAR_ __far
  26. #else 
  27. #define _HFAR_
  28. #endif 
  29.  
  30. class strstreambuf : public streambuf  {
  31. public:
  32.         strstreambuf();
  33.         strstreambuf(int);
  34.         strstreambuf(char _HFAR_ *, int, char _HFAR_ * = 0);
  35.         strstreambuf(unsigned char _HFAR_ *, int, unsigned char _HFAR_ * = 0);
  36.         strstreambuf(signed char _HFAR_ _HFAR_ *, int, signed char _HFAR_ * = 0);
  37.         strstreambuf(void _HFAR_ * (*a)(long), void (*f) (void _HFAR_ *));
  38.         ~strstreambuf();
  39.  
  40.     void    freeze(int =1);
  41.     char _HFAR_ * str();
  42.  
  43. virtual int overflow(int);
  44. virtual int underflow();
  45. virtual streambuf* setbuf(char  _HFAR_ *, int);
  46. virtual streampos seekoff(streamoff, ios::seek_dir, int);
  47. virtual int sync();     // not in spec.
  48.  
  49. protected:
  50. virtual int doallocate();
  51. private:
  52.     int x_dynamic;
  53.     int     x_bufmin;
  54.     int     _fAlloc;
  55.     int x_static;
  56.     void _HFAR_ * (* x_alloc)(long);
  57.     void    (* x_free)(void _HFAR_ *);
  58. };
  59.  
  60. class istrstream : public istream {
  61. public:
  62.         istrstream(char _HFAR_ *);
  63.         istrstream(char _HFAR_ *, int);
  64.         ~istrstream();
  65.  
  66. inline  strstreambuf* rdbuf() const { return (strstreambuf*) ios::rdbuf(); }
  67. inline  char _HFAR_ *   str() { return rdbuf()->str(); }
  68. };
  69.  
  70. class ostrstream : public ostream {
  71. public:
  72.         ostrstream();
  73.         ostrstream(char _HFAR_ *, int, int = ios::out);
  74.         ~ostrstream();
  75.  
  76. inline  int pcount() const { return rdbuf()->out_waiting(); }
  77. inline  strstreambuf* rdbuf() const { return (strstreambuf*) ios::rdbuf(); }
  78. inline  char _HFAR_ *   str() { return rdbuf()->str(); }
  79. };
  80.  
  81. class strstream : public iostream { // strstreambase ???
  82. public:
  83.         strstream();
  84.         strstream(char _HFAR_ *, int, int);
  85.         ~strstream();
  86.  
  87. inline  int pcount() const { return rdbuf()->out_waiting(); } // not in spec.
  88. inline  strstreambuf* rdbuf() const { return (strstreambuf*) ostream::rdbuf(); }
  89. inline  char _HFAR_ *   str() { return rdbuf()->str(); }
  90. };
  91.  
  92. // Restore default packing
  93. #pragma pack()
  94.  
  95. #endif 
  96.